package com.zansc.longd.controller;

import com.zansc.longd.domain.entity.s.Menu;
import com.zansc.longd.model.base.bean.ResponseBean;
import com.zansc.longd.model.base.in.MenuIn;
import com.zansc.longd.model.base.out.MenuOut;
import com.zansc.longd.model.code.BaseCodeInterface;
import com.zansc.longd.model.code.ErrorCode;
import com.zansc.longd.service.s.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("menu")
public class MenuController {
    
    @Autowired
    private MenuService menuService;
    
    @RequestMapping("addmenu")
    public ResponseBean addMenu(@RequestHeader("Authorization") String token) {
        //if (null == menuIn) {
        //    return ResponseBean.error(666, "空空");
        //}
        return ResponseBean.success();
    }
    
    @GetMapping("get")
    public ResponseBean get() {
        List<MenuOut> menu = menuService.getMenu();
        if (menu != null) {
            return ResponseBean.success(menu, "获取菜单成功");
        }
        return ResponseBean.error(404, "菜单不见了");
    }
    
}
